package me.young.android.fullscreengesture

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        menuInflater.inflate(R.menu.main, menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
        when (item!!.itemId) {
            R.id.service -> {
                if (!OpenAccessibilitySettingHelper.isAccessibilitySettingsOn(this,
                                FullScreenAccessService::class.java.name)) {
                    OpenAccessibilitySettingHelper.jumpToSettingPage(this)// 跳转到开启页面
                } else {
                    Toast.makeText(this, R.string.service_already_access, Toast.LENGTH_SHORT).show();
                }
            }
        }
        return super.onOptionsItemSelected(item)
    }
}
